/*
 * IC Project - a prototype to test a hypothesis of collective intelligence
 * Copyright (C) 2012 Paolo Conte - paolo@concavi.net
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.ix.data.manager;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.ix.data.entities.PeerInfo;

public class P2PBroker implements Serializable {

    static final long serialVersionUID = 9995834736484956L;
    private List<PeerInfo> peers = new <PeerInfo>ArrayList();
    public static final String PEERS = "peers";

    public P2PBroker() {
    }

    public List<PeerInfo> getPeers() {
        return peers;
    }

    public void setPeers(List<PeerInfo> peers) {
        if (comparePeers(this.peers, peers)) {
            this.peers = peers;
        }
    }
    
    public void addPeer(PeerInfo peer) {
        peers.add(peer);
    }
    
    public void removePeer(PeerInfo peer) {
        peers.remove(peer);
    }
    
    public int size() {
        return peers.size();
    }
    
    public boolean hasPeer(PeerInfo peer) {
        return peers.contains(peer);
    }

    private boolean comparePeers(List<PeerInfo> oldPeers, List<PeerInfo> newPeers) {
        return true;
    }
}
